<script>
	import Version from './common/versionUpdate.js'
	import * as oex from 'oex-web3';
	export default {
		onLaunch: function() {
			const _this = this;
			let language = _this._i18n.locale;
			
			language === 'en' ?  _this._i18n.locale = 'en' : _this._i18n.locale = 'zh_CN';
			uni.setStorageSync('system_info',language);
			if(uni.getStorageSync('login_status') && uni.getStorageSync('account_info')){
				uni.reLaunch({
					url: './pages/index/index'
				})
			}else{
				if(language){
					uni.reLaunch({
						url: './pages/login/login'
					})
				}else{
					uni.navigateTo({
						url:"./pages/start/start"
					})
				}
			}
			
			oex.utils.setApp();
			let nodeInfo = ""
			if(uni.getStorageSync('nodeInfo') == ""){
				uni.setStorageSync('nodeInfo','http://mainnet.oexchain.com');
				nodeInfo = "http://mainnet.oexchain.com"
			}else{
				nodeInfo = uni.getStorageSync('nodeInfo');
				
			}
			oex.utils.setProvider(nodeInfo);
			
			oex.oex.getChainConfig(true).then(chainConfig => {
				this.$CommonJS.request(nodeInfo, "POST", chainConfig).then(chainConfigInfo => {
					oex.oex.setChainConfig(chainConfigInfo.data.result);
					oex.oex.setChainId(chainConfigInfo.data.result.chainId);
				})
			})
			//版本更新
			Version.update();
			
		}
	}
</script>

<style lang="stylus">
	/*每个页面公共css */
</style>
